package com.yanqu.backendweb.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.yanqu.road.utils.ConfigHelper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DruidConfig {

    @Bean
    public DataSource dataSource() {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(ConfigHelper.getValue("spring.datasource.url"));
        datasource.setDriverClassName(ConfigHelper.getValue("spring.datasource.driver-class-name"));
        datasource.setUsername(ConfigHelper.getValue("spring.datasource.username"));
        datasource.setPassword(ConfigHelper.getValue("spring.datasource.password"));
        return datasource;
    }
}
